$(function() {
	$("#Button2").click(function() {
				document.location = context + "/site/creditOrganization/5.jsp";
			});

	var id = getParameter("5-1.js", "id");

	var jsonparams = {
		id : id,
		primaryTable : "fcapply",
		foreignTables : [{
					foreignTable : "fccontract",
					listid : "ctrlist",
					orderby : "CON_DATE",
					sort : "DESC"
				}, {
					foreignTable : "fctrc",
					listid : "trclist",
					orderby : "TRC_REGISTERSTART",
					sort : "DESC"
				}]
	}

	var view = new $.grooveViewPreII(jsonparams, "creditfc", {
				formID : "formView",
				beforecall : function() {

				},
				aftercall : null
			});

	grooveTableSelectorI({
				id : id,
				columnName : "au_id",
				tableName : "craudit",
				handleType : "single",
				initFunc : function(data) {
					if (data != null) {
						var auditParams = {
							id : data.PK_ID,
							primaryTable : "craudit"
						}

						var auditView = new $.grooveViewPreII(auditParams,
								"creditaudit4supplier", {
									submitMessage : "确定提交经销商资质审核结果",
									OKMessage : "成功提交经销商资质审核结果",
									submitButtonID : "Button1",
									formID : "formID",
									rendercall : function() {
										$("#au_name").val($("#fcname").val());
										$("#au_id").val(id);
									},
									aftercall : function() {
										document.location = context
												+ "/site/creditOrganization/5.jsp";
									}
								});
					} else {
						var auditView = new $.grooveView("creditaudit4supplier", {
									submitMessage : "确定提交经销商资质审核结果",
									OKMessage : "成功提交经销商资质审核结果",
									submitButtonID : "Button1",
									formID : "formID",
									rendercall : function() {
										$("#au_name").val($("#fcname").val());
										$("#au_id").val(id);
									},
									aftercall : function() {
										document.location = context
												+ "/site/creditOrganization/5.jsp";
									}
								});
					}
				}
			})

	$("#pageloading").hide();
});